package com.eastfair.venuebooking.enums;

import com.eastfair.annotation.base.BaseEnum;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

import java.util.stream.Stream;

/**
 * 跟进计划提醒方式 enum.
 *
 * @author dqq
 * @date 2023 /2/16
 */
@Getter
@AllArgsConstructor
@NoArgsConstructor
public enum FollowRemindWayEnum implements BaseEnum {

    /**
     * Sys message follow remind way enum.
     */
    SYS_MESSAGE("系统消息"),

    /**
     * Email follow remind way enum.
     */
    EMAIL("邮件"),

    /**
     * Short message follow remind way enum.
     */
    SHORT_MESSAGE("短信");

    @ApiModelProperty(value = "描述")
    private String desc;


    /**
     * 根据当前枚举的name匹配
     *
     * @param val the val
     * @param def the def
     * @return the follow remind way enum
     */
    public static FollowRemindWayEnum match(String val, FollowRemindWayEnum def) {
        return Stream.of(values()).parallel().filter(item -> item.name().equalsIgnoreCase(val)).findAny().orElse(def);
    }

    /**
     * Get follow remind way enum.
     *
     * @param val the val
     * @return the follow remind way enum
     */
    public static FollowRemindWayEnum get(String val) {
        return match(val, null);
    }

    /**
     * Eq boolean.
     *
     * @param val the val
     * @return the boolean
     */
    public boolean eq(FollowRemindWayEnum val) {
        return val != null && eq(val.name());
    }

    @Override
    public String getCode() {
        return this.name();
    }
}